import { ts, SwitchStatement, rule, BreakStatement, is, CallExpression, BinaryExpression } from "qvog-dsl";

const SEVERITY = 2;
const DOC_PATH = 'docs/consistent-type-imports-check.md';
const DESCRIPTION = 'Enforce consistent usage of type imports.';

let disallowTypeAnnotations = true;

function checkVariableStatement(node: ts.Node): boolean {
    const nodeList = node.getChildren();
    for (const child of nodeList) {
        if (ts.isImportTypeNode(child) && disallowTypeAnnotations) {
            return true;
        } else {
            const flag = checkVariableStatement(child);
            if (flag) {
                return true;
            }
        }
    }
    return false;
}

export default rule()
    .match((node): node is ts.VariableStatement => ts.isVariableStatement(node))
    .when((node): boolean => {
        return checkVariableStatement(node);
    })
    .report({
        severity: SEVERITY,
        description: DESCRIPTION,
        docPath: DOC_PATH,
    });
